class ApplicationController < ActionController::Base
   # Intialize
   before_filter :intialize
   # Put layout on every site
   layout "wiki_layout"
  
   private
   
   def authorize
     unless User.find_by_id(session[:user_id])
       flash[:notice] = "Please login"
       redirect_to(:controller => "../user", :action => "login")
     end
   end
   
    # Intilize
    def intialize  
      #defines first part of controller to determent source folder
    	@mcon = @params[:controller].split('/')[0]
 
     @user_id = @session[:user_id]
     @pagePublic = Page.find :all, :conditions => [ "user_id = ?", 0], :order => "title ASC"
     @pagePrivate = Page.find :all, :conditions => [ "user_id = ?", @user_id ], :order => "title ASC"
    end

    # Event handler
    def event_add (controller, action, id)
      @event = Event.new(:controller => controller,
                          :action => action,
                          :timestamp => Time.now,
                          :user_id => @session[:user_id],
                          :page_id => id)
      @event.save
    end
end